const routerURL  = 'https://newapi.shanqueyi.com/';
const baseUrl  = 'https://newapi.shanqueyi.com';
export function uniRequest (url, method, data) {
	return new Promise ((resolve, reject) => {
		uni.request({
			url: routerURL + url,
			method: method || 'GET',
			data: data || {},
			header: (method == 'POST' ?
						{ 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' } :
						{ 'Content-Type': 'application/x-www-form-urlencoded' }),
			success: res => {
				// console.log('url', url)
				if(res.data.code == "000000") {
					resolve(res.data);
				}else{
					uni.showToast({
						title: res.data.message, icon: 'none', duration: 3000
					});
				}
			},
			fail: err => {
				reject(err);
				uni.showToast({
					title: err.data.message, icon: 'none', duration: 3000
				});
			}
		});
	});
};